﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using OnlineStore.Dal;

namespace OnlineStore.Bll
{
    /// <summary>
    /// Summary description for ImageHttpHandler
    /// </summary>
    public class ImageHttpHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            try
            {
                string ProductID = context.Request.QueryString.Get("id").ToString();
                bizProduct _bizproduct = new bizProduct();
                tbProduct _product = _bizproduct.SearchPorduct(ProductID);
                if (_product != null)
                {
                    byte[] fileAsByte = (byte[])_product.Pro_Image.ToArray();
                    context.Response.BinaryWrite(fileAsByte);
                }
                context.Response.End();
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}